package com.example.demo.service;

import com.example.demo.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.jooq.impl.DSL;
import org.springframework.stereotype.Service;
import java.util.List;

@Slf4j
@Service
public class UserService extends BaseService<User> {

    public void test() {
        log.info("############ UserService.test() start");

        User user1 = new User();
        user1.setName("666");
        int n1 = this.insert(user1);
        log.info("n1: {}", n1);
        log.info("user1: {}", user1);

        User user2 = new User();
        user2.setId(user1.getId());
        user2.setName("999");
        int n2 = this.update(user2);
        log.info("n2: {}", n2);

        User user3 = this.selectById(user2.getId());
        log.info("user3: {}", user3);

        int n3 = this.delete(user3);
        log.info("n3: {}", n3);

        List<User> users = this.selectList(DSL.trueCondition());
        log.info("users: {}", users);

        log.info("############ UserService.test() end");
    }
}
